﻿using System;

namespace BizElements.Core
{
    /// <summary>Retrieves and compares entity primary keys.</summary>
    public interface IEntityKeyBinder
    {
        /// <summary>Gets or sets entity.</summary>
        IEntity EntityWithKey { get; set; }

        /// <summary>
        /// Gets the value(s) that uniquely identify an entity.
        /// In the order as specified in the accompanying IDbTable class.
        /// <b>Null</b> if the parent table/view doesn't have a primary key constraint or the required fields are not set.
        /// </summary>
        /// <returns>An object array that holds Primary Key values.</returns>
        object[] GetPrimaryKeyValue();

        /// <summary>
        /// Checks if the given values are equal to the primary key value of this entity.
        /// </summary>
        /// <param name="values">Values.</param>
        /// <returns>True if primary key values match the given values; false otherwise or if the PK fields 
        /// of this entity aren't set.</returns>
        bool PrimaryKeyEquals(object[] values);
    }
}
